﻿/***********************************************************************
 * <copyright file="MapperDto.cs" company="BUCA JSC">
 * -->    Copyright (C) statement. All right reserved
 * </copyright>
 * 
 * Created:   Tuanhm
 * Email:    Tuanhm@humg@gmail.com
 * Website:
 * Create Date: Thursday, March 27, 2014
 * Usage: 
 * 
 * RevisionHistory: 
 * Date         Author               Description 
 * 
 * ************************************************************************/


using System.Linq;
using System.Collections.Generic;
using AcountingService.DataTransferObjects.Dictionary;
using AcountingService.DataTransferObjects.Report;
using BusinessObjects.BussinessDictionary;
using BusinessObjects.Report;
using BusinessObjects.Report.Voucher;

namespace AcountingService.DataTransferObjectMapper
{
    /// <summary>
    /// Maps DTOs (Data Transfer Objects) to BOs (Business Objects) and vice versa.
    /// </summary>
    public static class Mapper
    {

        #region ToDataTransferObjects

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static IList<UnitDto> ToDataTransferObjects(IEnumerable<Unit> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static IList<CustomerDto> ToDataTransferObjects(IEnumerable<Customer> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static IList<VendorDto> ToDataTransferObjects(IEnumerable<Vendor> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static IList<VoucherTypeDto> ToDataTransferObjects(IEnumerable<VoucherType> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static IList<RefTypeDto> ToDataTransferObjects(IEnumerable<RefType> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static IList<AutoBusinessDto> ToDataTransferObjects(IEnumerable<AutoBusiness> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToList();
        }


        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static IList<DbOptionDto> ToDataTransferObjects(IEnumerable<DbOption> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToList();
        }

        /// <summary>to
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<StockDto> ToDataTransferObjects(IEnumerable<Stock> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToList();
        }

        /// <summary>to
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<InventoryItemDto> ToDataTransferObjects(IEnumerable<InventoryItem> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToList();
        }

        /// <summary>to
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<AccountDto> ToDataTransferObjects(IEnumerable<Account> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToList();
        }


        /// <summary>to
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<DepartmentDto> ToDataTransferObjects(IEnumerable<Department> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToList();
        }
        /// <summary>to
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<EmployTestDto> ToDataTransferObjects(IEnumerable<EmployTest> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToList();
        }

        /// <summary>to
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<ReportGroupDto> ToDataTransferObjects(IEnumerable<ReportGroup> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToList();
        }

        /// <summary>to
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<ReportListDto> ToDataTransferObjects(IEnumerable<ReportList> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToList();
        }

        /// <summary>to
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<FixedAssetDto> ToDataTransferObjects(IEnumerable<FixedAsset> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToList();
        }

        /// <summary>to
        /// To the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<FixedAssetCategoryDto> ToDataTransferObjects(IEnumerable<FixedAssetCategory> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToList();
        }

        public static IList<StockBacklogDto> ToDataTransferObjects(IEnumerable<StockBacklogEntity> c)
        {
            return c == null ? null : c.Select(source => ToDataTransferObject((source))).ToList();
        }
        #endregion

        #region ToDataTransferObject.

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <returns></returns>
        public static UnitDto ToDataTransferObject(Unit c)
        {
            if (c == null) return null;
            return new UnitDto
            {

                UnitId = c.UnitId,
                ParentId = c.ParentId,
                Code = c.Code,
                Name = c.Name,
                Grade = c.Grade,
                IsActive = c.IsActive,
                HasParent = c.HasParent,
                PhoneNumber = c.PhoneNumber,
                Address = c.Address,
                ByManagement = c.ByManagement,
            };
        }


        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <returns></returns>
        public static CustomerDto ToDataTransferObject(Customer c)
        {
            if (c == null) return null;
            return new CustomerDto
            {
                CustomerId = c.CustomerId,
                UnitId = c.UnitId,
                Code = c.Code,
                Name = c.Name,
                Address = c.Address,
                PhoneNumber = c.PhoneNumber,
                Fax = c.Fax,
                CompanyName = c.CompanyName,
                ContactName = c.ContactName,
                Description = c.Description,
                IsActive = c.IsActive,
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <returns></returns>
        public static VendorDto ToDataTransferObject(Vendor c)
        {
            if (c == null) return null;
            return new VendorDto
            {
                VendorId = c.VendorId,
                Code = c.Code,
                Name = c.Name,
                Address = c.Address,
                ContactName = c.ContactName,
                PhoneNumber = c.PhoneNumber,
                Description = c.Description,
                Fax = c.Fax,
                IsActive = c.IsActive,
                UnitId = c.UnitId,
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <returns></returns>
        public static VoucherTypeDto ToDataTransferObject(VoucherType c)
        {
            if (c == null) return null;
            return new VoucherTypeDto
            {
                VoucherTypeId = c.VoucherTypeId,
                VoucherTypeName = c.VoucherTypeName,
                IsActive = c.IsActive
            };
        }
        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <returns></returns>
        public static AutoNumberDto ToDataTransferObject(AutoNumber c)
        {
            if (c == null) return null;
            return new AutoNumberDto
            {
                AutoId = c.AutoId,
                UnitId = c.UnitId,
                LengthOfValue = c.LengthOfValue,
                Prefix = c.Prefix,
                RefTypeId = c.RefTypeId,
                Suffix = c.Suffix,
                Value = c.Value
            };
        }
        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <returns></returns>
        public static RefTypeDto ToDataTransferObject(RefType c)
        {
            if (c == null) return null;
            return new RefTypeDto
            {
                RefTypeId = c.RefTypeId,
                MasterTable = c.MasterTable,
                Name = c.Name,
                DetailTable = c.DetailTable,
                Description = c.Description,
                IsActive = c.IsActive,
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <returns></returns>
        public static AutoBusinessDto ToDataTransferObject(AutoBusiness c)
        {
            if (c == null) return null;
            return new AutoBusinessDto
            {
                AutoBusinessId = c.AutoBusinessId,
                AutoBusinessCode = c.AutoBusinessCode,
                AutoBusinessName = c.AutoBusinessName,
                RefTypeId = c.RefTypeId,
                VoucherTypeId = c.VoucherTypeId,
                DebitAccountNumber = c.DebitAccountNumber,
                CreditAccountNumber = c.CreditAccountNumber,
                Description = c.Description,
                IsActive = c.IsActive,
                UnitId = c.UnitId
            };
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="dbOption"></param>
        /// <returns></returns>
        public static DbOptionDto ToDataTransferObject(DbOption dbOption)
        {
            if (dbOption == null) return null;

            return new DbOptionDto
            {
                OptionId = dbOption.OptionId,
                UnitId = dbOption.UnitId,
                Code = dbOption.Code,
                Value = dbOption.Value,
                ValueType = dbOption.ValueType,
                Description = dbOption.Description,
                IsSystem = dbOption.IsSystem
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static StockDto ToDataTransferObject(Stock c)
        {
            if (c == null) return null;

            return new StockDto
            {
                StockId = c.StockId,
                StockCode = c.StockCode,
                StockName = c.StockName,
                Description = c.Description,
                IsActive = c.IsActive,
                UnitId = c.UnitId
            };
        }

        public static InventoryItemDto ToDataTransferObject(InventoryItem c)
        {
            if (c == null) return null;

            return new InventoryItemDto
            {
                InventoryItemId = c.InventoryItemId,
                InventoryItemName = c.InventoryItemName,
                InventoryItemCode = c.InventoryItemCode,
                AccountCode = c.AccountCode,
                //  CurrencyCode = fixedAsset.CurrencyCode,
                IsActive = c.IsActive,
                //  CostMethod = fixedAsset.CostMethod,
                Unit = c.Unit,
                UnitId = c.UnitId
            };
        }

        /// <summary>
        /// Froms the data transfer object.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static AccountDto ToDataTransferObject(Account c)
        {
            if (c == null) return null;

            return new AccountDto
            {
                AccountId = c.AccountId,
                UnitId = c.UnitId,
                AccountCode = c.AccountCode,
                AccountName = c.AccountName,
                ParentId = c.ParentId,
                Grade = c.Grade,
                IsDetail = c.IsDetail,
                Description = c.Description,
                IsCustomer = c.IsCustomer,
                IsVendor = c.IsVendor,
                IsTax = c.IsTax,
                IsInventoryItem = c.IsInventoryItem,
                IsFixedAsset = c.IsFixedAsset,
                IsActive = c.IsActive,
                IsSystem = c.IsSystem,
                BalanceSide = c.BalanceSide,
            };
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        public static DepartmentDto ToDataTransferObject(Department c)
        {
            if (c == null) return null;

            return new DepartmentDto
            {
                DepartmentId = c.DepartmentId,
                UnitId = c.UnitId,
                Code = c.Code,
                Name = c.Name,
                Address = c.Address,
                Description = c.Description,
                IsActive = c.IsActive,
                Fax = c.Fax,
                PhoneNumber = c.PhoneNumber,
                ParentId = c.ParentId,
            };
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        public static EmployTestDto ToDataTransferObject(EmployTest c)
        {
            if (c == null) return null;

            return new EmployTestDto
            {
                EmployId = c.EmployId,
                Name = c.Name,
                Salary = c.Salary,
                DepartmentId = c.DepartmentId
            };
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="reportGroup"> </param>
        /// <returns></returns>
        public static ReportGroupDto ToDataTransferObject(ReportGroup reportGroup)
        {
            if (reportGroup == null) return null;

            return new ReportGroupDto
            {
                ReportGroupId = reportGroup.ReportGroupId,
                Name = reportGroup.Name,
                IsVoucher = reportGroup.IsVoucher,
                Description = reportGroup.Description,
                IsActive = reportGroup.IsActive,
                IsTypical = reportGroup.IsTypical
            };
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="fixedAssetCategory"> </param>
        /// <returns></returns>
        public static ReportListDto ToDataTransferObject(ReportList fixedAssetCategory)
        {
            if (fixedAssetCategory == null) return null;

            return new ReportListDto
            {
                ReportListId = fixedAssetCategory.ReportListId,
                ReportGroupId = fixedAssetCategory.ReportGroupId,
                Name = fixedAssetCategory.Name,
                File = fixedAssetCategory.File,
                InputTypeName = fixedAssetCategory.InputTypeName,
                FunctionReportName = fixedAssetCategory.FunctionReportName,
                ProcedureReportName = fixedAssetCategory.ProcedureReportName,
                TableName = fixedAssetCategory.TableName,
                Grade = fixedAssetCategory.Grade,
                SortOrder = fixedAssetCategory.SortOrder,
                IsTypical = fixedAssetCategory.IsTypical,
                Description = fixedAssetCategory.Description,
                IsActive = fixedAssetCategory.IsActive,
                Code = fixedAssetCategory.Code,
                ReportController = fixedAssetCategory.ReportController,
                ParentId = fixedAssetCategory.ParentId
            };
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static FixedAssetDto ToDataTransferObject(FixedAsset fixedAsset)
        {
            if (fixedAsset == null) return null;

            return new FixedAssetDto
            {
                FixedAssetId = fixedAsset.FixedAssetId,
                FixedAssetCode = fixedAsset.FixedAssetCode,
                FixedAssetName = fixedAsset.FixedAssetName,
                FixedAssetCategoryId = fixedAsset.FixedAssetCategoryId,
                State = fixedAsset.State,
                Description = fixedAsset.Description,
                ProductionYear = fixedAsset.ProductionYear,
                MadeIn = fixedAsset.MadeIn,
                PurchasedDate = fixedAsset.PurchasedDate,
                UsedDate = fixedAsset.UsedDate,
                DepreciationDate = fixedAsset.DepreciationDate,
                IncrementDate = fixedAsset.IncrementDate,
                DisposedDate = fixedAsset.DisposedDate,
                Unit = fixedAsset.Unit,
                SerialNumber = fixedAsset.SerialNumber,
                Accessories = fixedAsset.Accessories,
                Quantity = fixedAsset.Quantity,
                UnitPrice = fixedAsset.UnitPrice,
                OrgPrice = fixedAsset.OrgPrice,
                AccumDepreciationAmount = fixedAsset.AccumDepreciationAmount,
                RemainingAmount = fixedAsset.RemainingAmount,
                AnnualDepreciationAmount = fixedAsset.AnnualDepreciationAmount,
                LifeTime = fixedAsset.LifeTime,
                DepreciationRate = fixedAsset.DepreciationRate,
                OrgPriceAccountCode = fixedAsset.OrgPriceAccountCode,
                DepreciationAccountCode = fixedAsset.DepreciationAccountCode,
                CapitalAccountCode = fixedAsset.CapitalAccountCode,
                DepartmentId = fixedAsset.DepartmentId,
                EmployeeId = fixedAsset.EmployeeId,
                IsActive = fixedAsset.IsActive,
                CapitalMoneyAccountCode = fixedAsset.CapitalMoneyAccountCode,
                ExpenseAccountCode = fixedAsset.ExpenseAccountCode,
                UnitId = fixedAsset.UnitId
            };
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="fixedAssetCategory"> </param>
        /// <returns></returns>
        public static FixedAssetCategoryDto ToDataTransferObject(FixedAssetCategory fixedAssetCategory)
        {
            if (fixedAssetCategory == null) return null;

            return new FixedAssetCategoryDto
            {
                FixedAssetCategoryId = fixedAssetCategory.FixedAssetCategoryId,
                ParentId = fixedAssetCategory.ParentId,
                FixedAssetCategoryCode = fixedAssetCategory.FixedAssetCategoryCode,
                FixedAssetCategoryName = fixedAssetCategory.FixedAssetCategoryName,
                DepreciationRate = fixedAssetCategory.DepreciationRate,
                LifeTime = fixedAssetCategory.LifeTime,
                Grade = fixedAssetCategory.Grade,
                IsParent = fixedAssetCategory.IsParent,
                OrgPriceAccountCode = fixedAssetCategory.OrgPriceAccountCode,
                DepreciationAccountCode = fixedAssetCategory.DepreciationAccountCode,
                CapitalAccountCode = fixedAssetCategory.CapitalAccountCode,
                IsActive = fixedAssetCategory.IsActive,
                UnitId = fixedAssetCategory.UnitId
            };
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="stockBacklog"> </param>
        /// <returns></returns>
        public static StockBacklogDto ToDataTransferObject(StockBacklogEntity stockBacklog)
        {
            if (stockBacklog == null) return null;

            return new StockBacklogDto
            {
                InventoryItemCode = stockBacklog.InventoryItemCode,
                InventoryItemName = stockBacklog.InventoryItemName,
                Unit = stockBacklog.Unit,
                QuantityOpening = stockBacklog.QuantityOpening,
                QuantityInwardStock = stockBacklog.QuantityInwardStock,
                QuantityOutwardStock = stockBacklog.QuantityOutwardStock,
                QuantityClosing = stockBacklog.QuantityClosing,

                OrgPriceClosing = stockBacklog.OrgPriceClosing,
                OrgPriceInwardStock = stockBacklog.OrgPriceInwardStock,
                OrgPriceOpening = stockBacklog.OrgPriceOpening,
                OrgPriceOutwardStock = stockBacklog.OrgPriceOutwardStock,
            };
        }

        #endregion

        #region FromDataTransferObject
        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <returns></returns>
        public static Unit FromDataTransferObject(UnitDto c)
        {
            if (c == null) return null;
            return new Unit
            {
                UnitId = c.UnitId,
                ParentId = c.ParentId,
                Code = c.Code,
                Name = c.Name,
                Grade = c.Grade,
                IsActive = c.IsActive,
                HasParent = c.HasParent,
                PhoneNumber = c.PhoneNumber,
                Address = c.Address,
                ByManagement = c.ByManagement,
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <returns></returns>
        public static Customer FromDataTransferObject(CustomerDto c)
        {
            if (c == null) return null;
            return new Customer
            {
                CustomerId = c.CustomerId,
                UnitId = c.UnitId,
                Code = c.Code,
                Name = c.Name,
                Address = c.Address,
                PhoneNumber = c.PhoneNumber,
                Fax = c.Fax,
                CompanyName = c.CompanyName,
                ContactName = c.ContactName,
                Description = c.Description,
                IsActive = c.IsActive,
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <returns></returns>
        public static Vendor FromDataTransferObject(VendorDto c)
        {
            if (c == null) return null;
            return new Vendor
            {
                VendorId = c.VendorId,
                Code = c.Code,
                Name = c.Name,
                Address = c.Address,
                ContactName = c.ContactName,
                PhoneNumber = c.PhoneNumber,
                Description = c.Description,
                Fax = c.Fax,
                IsActive = c.IsActive,
                UnitId = c.UnitId,
            };
        }


        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <returns></returns>
        public static VoucherType FromDataTransferObject(VoucherTypeDto c)
        {
            if (c == null) return null;
            return new VoucherType
            {
                VoucherTypeId = c.VoucherTypeId,
                VoucherTypeName = c.VoucherTypeName,
                IsActive = c.IsActive
            };
        }

        /// <summary>
        /// To the data transfer object.
        /// </summary>
        /// <returns></returns>
        public static RefType FromDataTransferObject(RefTypeDto c)
        {
            if (c == null) return null;
            return new RefType
            {
                RefTypeId = c.RefTypeId,
                MasterTable = c.MasterTable,
                Name = c.Name,
                DetailTable = c.DetailTable,
                Description = c.Description,
                IsActive = c.IsActive,
            };
        }

        /// <summary>
        /// Froms the data transfer object.
        /// </summary>
        /// <returns></returns>
        public static AutoBusiness FromDataTransferObject(AutoBusinessDto c)
        {
            if (c == null) return null;

            return new AutoBusiness
            {
                AutoBusinessId = c.AutoBusinessId,
                AutoBusinessCode = c.AutoBusinessCode,
                AutoBusinessName = c.AutoBusinessName,
                RefTypeId = c.RefTypeId,
                VoucherTypeId = c.VoucherTypeId,
                DebitAccountNumber = c.DebitAccountNumber,
                CreditAccountNumber = c.CreditAccountNumber,
                // BudgetSourceCode = fixedAsset.BudgetSourceCode,
                // BudgetItemCode = fixedAsset.BudgetItemCode,
                Description = c.Description,
                IsActive = c.IsActive,
                UnitId = c.UnitId
            };
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        public static DbOption FromDataTransferObject(DbOptionDto c)
        {
            if (c == null) return null;

            return new DbOption
            {
                OptionId = c.OptionId,
                UnitId = c.UnitId,
                Code = c.Code,
                Value = c.Value,
                ValueType = c.ValueType,
                Description = c.Description,
                IsSystem = c.IsSystem
            };
        }

        public static Stock FromDataTransferObject(StockDto c)
        {
            if (c == null) return null;

            return new Stock
            {
                StockId = c.StockId,
                StockCode = c.StockCode,
                StockName = c.StockName,
                Description = c.Description,
                IsActive = c.IsActive,
                UnitId = c.UnitId
            };
        }

        public static InventoryItem FromDataTransferObject(InventoryItemDto c)
        {
            if (c == null) return null;

            return new InventoryItem
            {
                InventoryItemId = c.InventoryItemId,
                InventoryItemName = c.InventoryItemName,
                InventoryItemCode = c.InventoryItemCode,
                AccountCode = c.AccountCode,
                //  CurrencyCode = fixedAsset.CurrencyCode,
                IsActive = c.IsActive,
                //  CostMethod = fixedAsset.CostMethod,
                Unit = c.Unit,
                UnitId = c.UnitId
            };
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        public static Department FromDataTransferObject(DepartmentDto c)
        {
            if (c == null) return null;

            return new Department
            {
                DepartmentId = c.DepartmentId,
                UnitId = c.UnitId,
                Code = c.Code,
                Name = c.Name,
                Address = c.Address,
                Description = c.Description,
                IsActive = c.IsActive,
                Fax = c.Fax,
                PhoneNumber = c.PhoneNumber,
                ParentId = c.ParentId,
            };
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        public static EmployTest FromDataTransferObject(EmployTestDto c)
        {
            if (c == null) return null;

            return new EmployTest
            {
                EmployId = c.EmployId,
                Name = c.Name,
                Salary = c.Salary,
                DepartmentId = c.DepartmentId
            };
        }

        /// <summary>
        /// Froms the data transfer object.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static Account FromDataTransferObject(AccountDto c)
        {
            if (c == null) return null;

            return new Account
            {
                AccountId = c.AccountId,
                UnitId = c.UnitId,
                AccountCode = c.AccountCode,
                AccountName = c.AccountName,
                ParentId = c.ParentId,
                Grade = c.Grade,
                IsDetail = c.IsDetail,
                Description = c.Description,
                IsCustomer = c.IsCustomer,
                IsVendor = c.IsVendor,
                IsTax = c.IsTax,
                IsInventoryItem = c.IsInventoryItem,
                IsFixedAsset = c.IsFixedAsset,
                IsActive = c.IsActive,
                IsSystem = c.IsSystem,
                BalanceSide = c.BalanceSide,
            };
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        public static ReportGroup FromDataTransferObject(ReportGroupDto c)
        {
            if (c == null) return null;

            return new ReportGroup
            {
                ReportGroupId = c.ReportGroupId,
                Name = c.Name,
                IsVoucher = c.IsVoucher,
                Description = c.Description,
                IsActive = c.IsActive,
                IsTypical = c.IsTypical
            };
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        public static ReportList FromDataTransferObject(ReportListDto c)
        {
            if (c == null) return null;

            return new ReportList
            {
                ReportListId = c.ReportListId,
                ReportGroupId = c.ReportGroupId,
                Name = c.Name,
                File = c.File,
                InputTypeName = c.InputTypeName,
                FunctionReportName = c.FunctionReportName,
                ProcedureReportName = c.ProcedureReportName,
                TableName = c.TableName,
                Grade = c.Grade,
                SortOrder = c.SortOrder,
                IsTypical = c.IsTypical,
                Description = c.Description,
                IsActive = c.IsActive,
                Code = c.Code,
                ReportController = c.ReportController,
                ParentId = c.ParentId
            };
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        public static FixedAsset FromDataTransferObject(FixedAssetDto c)
        {
            if (c == null) return null;

            return new FixedAsset
            {
                FixedAssetId = c.FixedAssetId,
                FixedAssetCode = c.FixedAssetCode,
                FixedAssetName = c.FixedAssetName,
                FixedAssetCategoryId = c.FixedAssetCategoryId,
                State = c.State,
                Description = c.Description,
                ProductionYear = c.ProductionYear,
                MadeIn = c.MadeIn,
                PurchasedDate = c.PurchasedDate,
                UsedDate = c.UsedDate,
                DepreciationDate = c.DepreciationDate,
                IncrementDate = c.IncrementDate,
                DisposedDate = c.DisposedDate,
                Unit = c.Unit,
                SerialNumber = c.SerialNumber,
                Accessories = c.Accessories,
                Quantity = c.Quantity,
                UnitPrice = c.UnitPrice,
                OrgPrice = c.OrgPrice,
                AccumDepreciationAmount = c.AccumDepreciationAmount,
                RemainingAmount = c.RemainingAmount,
                AnnualDepreciationAmount = c.AnnualDepreciationAmount,
                LifeTime = c.LifeTime,
                DepreciationRate = c.DepreciationRate,
                OrgPriceAccountCode = c.OrgPriceAccountCode,
                DepreciationAccountCode = c.DepreciationAccountCode,
                CapitalAccountCode = c.CapitalAccountCode,
                DepartmentId = c.DepartmentId,
                EmployeeId = c.EmployeeId,
                IsActive = c.IsActive,
                CapitalMoneyAccountCode = c.CapitalMoneyAccountCode,
                ExpenseAccountCode = c.ExpenseAccountCode,
                UnitId = c.UnitId
            };
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        public static FixedAssetCategory FromDataTransferObject(FixedAssetCategoryDto c)
        {
            if (c == null) return null;

            return new FixedAssetCategory
            {
                FixedAssetCategoryId = c.FixedAssetCategoryId,
                ParentId = c.ParentId,
                FixedAssetCategoryCode = c.FixedAssetCategoryCode,
                FixedAssetCategoryName = c.FixedAssetCategoryName,
                DepreciationRate = c.DepreciationRate,
                LifeTime = c.LifeTime,
                Grade = c.Grade,
                IsParent = c.IsParent,
                OrgPriceAccountCode = c.OrgPriceAccountCode,
                DepreciationAccountCode = c.DepreciationAccountCode,
                CapitalAccountCode = c.CapitalAccountCode,
                IsActive = c.IsActive,
                UnitId = c.UnitId
            };
        }
        #endregion

        #region FromDataTransferObjects

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static IList<Unit> FromDataTransferObjects(IEnumerable<UnitDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static IList<Customer> FromDataTransferObjects(IEnumerable<CustomerDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static IList<Vendor> FromDataTransferObjects(IEnumerable<VendorDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }


        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static IList<VoucherType> FromDataTransferObjects(IEnumerable<VoucherTypeDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static IList<RefType> FromDataTransferObjects(IEnumerable<RefTypeDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }


        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static IList<AutoBusiness> FromDataTransferObjects(IEnumerable<AutoBusinessDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static IList<DbOption> FromDataTransferObjects(IEnumerable<DbOptionDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// Froms the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<Stock> FromDataTransferObjects(IEnumerable<StockDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// Froms the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<InventoryItem> FromDataTransferObjects(IEnumerable<InventoryItemDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// Froms the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<Account> FromDataTransferObjects(IEnumerable<AccountDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// Froms the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<Department> FromDataTransferObjects(IEnumerable<DepartmentDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }
        /// <summary>
        /// Froms the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<EmployTest> FromDataTransferObjects(IEnumerable<EmployTestDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// Froms the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<ReportList> FromDataTransferObjects(IEnumerable<ReportListDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// Froms the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<ReportGroup> FromDataTransferObjects(IEnumerable<ReportGroupDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// Froms the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<FixedAsset> FromDataTransferObjects(IEnumerable<FixedAssetDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }

        /// <summary>
        /// Froms the data transfer objects.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <returns></returns>
        public static IList<FixedAssetCategory> FromDataTransferObjects(IEnumerable<FixedAssetCategoryDto> c)
        {
            return c == null ? null : c.Select(source => FromDataTransferObject((source))).ToList();
        }
        #endregion
    }
}